import axios from "axios";
import {getToken} from "@/auth";

const BASE_URL = 'http://localhost'
const PORT = '3002'
 const axiosInstance = axios.create({
    baseURL: BASE_URL + ":" + PORT
})

axiosInstance.interceptors.request.use((config) => {
    // 如果请求路径不是 '/getCode' 或者 '/user/login'，则在 header 中添加 Authorization 字段
    if (config.url !== '/verification/getCode' && config.url !== '/user/login') {
        config.headers['Authorization'] = 'Bearer ' + getToken();
        console.log("加上header")
    }
    return config
})

export default axiosInstance;
